<template>
    <div class="l-from-body" >
        <el-form :model="formData" :rules="rules" size="mini"  ref="form" label-width="120px" >
            <el-col :span="24" v-if="lr_hasPageAuth('f_FullName')">
                <el-form-item :label="$t('名称')" prop="f_FullName">
                    <el-input v-model="formData.f_FullName" :readonly="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="24" v-if="lr_hasPageAuth('f_ShortName')">
                <el-form-item :label="$t('简称')" prop="f_ShortName">
                    <el-input v-model="formData.f_ShortName" :readonly="true"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="24" v-if="lr_hasPageAuth('f_EnCode')">
                <el-form-item :label="$t('编码')" prop="f_EnCode">
                    <el-input v-model="formData.f_EnCode" :readonly="true"></el-input>
                </el-form-item>
            </el-col>

            <el-col :span="24" v-if="lr_hasPageAuth('f_DingAppKey')">
                <el-form-item label="DingAppKey" prop="f_DingAppKey">
                    <el-input v-model="formData.f_DingAppKey" :placeholder="$t('请输入应用的唯一标识key')"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="24" v-if="lr_hasPageAuth('f_DingAppSecret')">
                <el-form-item label="DingAppSecret" prop="f_DingAppSecret">
                    <el-input v-model="formData.f_DingAppSecret" :placeholder="$t('请输入应用的密钥')"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="24" v-if="lr_hasPageAuth('f_DingAgentId')">
                <el-form-item label="DingAgentId" prop="f_DingAgentId">
                    <el-input v-model="formData.f_DingAgentId" :placeholder="$t('请输入钉钉应用ID')"></el-input>
                </el-form-item>
            </el-col>

        </el-form>
    </div>
</template>
<script>
export default {
    data(){
        return {
            formData:{
                f_DingAppKey:'',
                f_DingAppSecret:'',
                f_DingAgentId:''
            },
            rules: {
                f_DingAppKey: [
                    { required: true, message: '请输入DingAppKey' ,trigger: 'null'}
                ],
                f_DingAppSecret: [
                    { required: true, message: '请输入DingAppSecret',trigger: 'null' }
                ],
                f_DingAgentId: [
                    { required: true, message: '请输入DingAgentId' ,trigger: 'null'}
                ]
            }
        };
    },
    created () {
        this.lr_loadDataItem('CompanyNature')
    },
    computed:{
        companyTree(){
            return this.$toTree(this.lr_companyList,"f_CompanyId","f_ParentId","f_CompanyId","f_FullName",[this.formData.f_CompanyId])
        },
    },
    methods:{
        resetForm(){
            this.$refs.form && this.$refs.form.resetFields()
        },
        // 校验表单
        validateForm(callback){
            this.$refs.form.validate((valid) => {
                if(valid){
                    callback()
                }
            })
        },
        setForm(data){
            const formData = this.$deepClone(data)
            this.formData = formData
        },
        getForm(){
            return this.$deepClone(this.formData)
        }
    }
}
</script>